#include <iostream>
#include "./SQL/SqlHelper.hpp"

int main()
{
    std::string sql = "select * from Users;";
    MYSQL *mysql = mysql_init(nullptr);

    // 连接数据库
    if (nullptr == mysql_real_connect(mysql, host.c_str(), DB_user.c_str(), DB_passwd.c_str(), "VR", port, nullptr, 0))
    {
        LOG(FATAL) << "连接数据库失败!" << "\n";
        
    }
    mysql_set_character_set(mysql, "utf8");
    LOG(INFO) << "连接数据库成功!" << "\n";
    std::string out ;
    std::vector<Users> result;
    if(!DatabaseOperation(mysql, sql, OperationType::SELECT, buildTableColumns<Users>(), &out, &result))
    {
        std::cout << "error Query" << std::endl;
    }
    std::cout << out << std::endl;

    for(auto user: result)
    {
        std::cout << user.UserID << std::endl;
        std::cout << user.UserName << std::endl;
        std::cout << user.Update_time << std::endl;
        std::cout << user.Password << std::endl;
        std::cout << user.Create_time << std::endl;
    }
    return 0;
}